<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>导航菜单</title>
    <style>
        /* 导航菜单样式 */
        body {
            margin: 0;
            padding: 0;
            background-color: #333;
            color: #fff;
            font-family: "Microsoft YaHei", "SimSun", serif;
        }
        
        .nav-container {
            padding: 20px 0;
        }
        
        .nav-title {
            text-align: center;
            padding: 15px;
            font-size: 18px;
            font-weight: bold;
            background-color: #555;
            border-bottom: 2px solid #777;
        }
        
        .nav-menu {
            list-style: none;
            padding: 0;
            margin: 0;
        }
        
        .nav-item {
            position: relative;
        }
        
        .nav-link {
            display: block;
            padding: 12px 20px;
            color: #fff;
            text-decoration: none;
            background-color: #444;
            border-bottom: 1px solid #555;
            transition: background-color 0.3s;
        }
        
        .nav-link:hover {
            background-color: #666;
        }
        
        /* 二级下拉菜单 */
        .dropdown {
            position: relative;
        }
        
        .dropdown-content {
            display: none;
            position: absolute;
            left: 100%;
            top: 0;
            width: 180px;
            background-color: #555;
            z-index: 1000;
        }
        
        .dropdown:hover .dropdown-content {
            display: block;
        }
        
        .dropdown-item {
            list-style: none;
            margin: 0;
            padding: 0;
        }
        
        .dropdown-link {
            display: block;
            padding: 10px 15px;
            color: #fff;
            text-decoration: none;
            border-bottom: 1px solid #666;
            transition: background-color 0.3s;
        }
        
        .dropdown-link:hover {
            background-color: #777;
        }
        
        /* 音乐控制按钮 */
        .music-control {
            text-align: center;
            padding: 15px;
            margin-top: 20px;
        }
        
        .music-btn {
            padding: 8px 15px;
            background-color: #8B4513;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-family: "Microsoft YaHei", "SimSun", serif;
            transition: background-color 0.3s;
        }
        
        .music-btn:hover {
            background-color: #A0522D;
        }
        
        /* 图标样式 */
        .icon {
            display: inline-block;
            margin-right: 8px;
        }
        
        /* 音乐状态提示 */
        .music-status {
            margin-top: 10px;
            font-size: 12px;
            color: #aaa;
        }
        
        .music-status.error {
            color: #ff6b6b;
        }
        
        .music-status.success {
            color: #51cf66;
        }
    </style>
</head>
<body>
    <div class="nav-container">
        <div class="nav-title">网站导航</div>
        
        <ul class="nav-menu">
            <li class="nav-item">
                <a href="content.html" target="mainFrame" class="nav-link">
                    <span class="icon">🏠</span>首页
                </a>
            </li>
            
            <li class="nav-item dropdown">
                <a href="javascript:void(0);" class="nav-link">
                    <span class="icon">🏞️</span>景点介绍 ▼
                </a>
                <ul class="dropdown-content">
                    <li class="dropdown-item">
                        <a href="west-lake.html" target="mainFrame" class="dropdown-link">杭州西湖</a>
                    </li>
                    <li class="dropdown-item">
                        <a href="siming-mountain.html" target="mainFrame" class="dropdown-link">余姚四明山</a>
                    </li>
                    <li class="dropdown-item">
                        <a href="luxun-residence.html" target="mainFrame" class="dropdown-link">绍兴鲁迅故居</a>
                    </li>
                </ul>
            </li>
            
            <li class="nav-item">
                <a href="puzzle-game.html" target="mainFrame" class="nav-link">
                    <span class="icon">🧩</span>拼图游戏
                </a>
            </li>
            
            <li class="nav-item">
                <a href="about.html" target="mainFrame" class="nav-link">
                    <span class="icon">ℹ️</span>关于我们
                </a>
            </li>
        </ul>
        
        <!-- 音乐控制 -->
        <div class="music-control">
            <button id="musicToggle" class="music-btn">
                <span id="musicIcon">▶️</span> 播放音乐
            </button>
            <div id="musicStatus" class="music-status">点击按钮播放音乐</div>
            <audio id="backgroundMusic" loop>
                <!-- 使用多种格式确保兼容性 -->
                <source src="D:/AI/前端学习/sound/凤凰传奇 - 荷塘月色.mp3" type="audio/mpeg">
                <source src="../sound/凤凰传奇 - 荷塘月色.mp3" type="audio/mpeg">
                <source src="../sound/凤凰传奇 - 荷塘月色.wav" type="audio/wav">
                您的浏览器不支持音频播放
            </audio>
            <p style="font-size:12px; color:#888;">注意：并不是所有的浏览器都能支持所有的音频格式，如果您的浏览器无法播放音乐，可能是音频格式不兼容或者浏览器不支持。</p>
        </div>
    </div>
    
    <script>
        // 背景音乐控制
        const musicToggle = document.getElementById('musicToggle');
        const backgroundMusic = document.getElementById('backgroundMusic');
        const musicIcon = document.getElementById('musicIcon');
        const musicStatus = document.getElementById('musicStatus');
        
        let isPlaying = false;
        
        // 预加载音乐
        backgroundMusic.preload = "auto";
        
        // 添加音乐加载状态监听
        backgroundMusic.addEventListener('loadeddata', function() {
            musicStatus.textContent = "音乐已加载，可以播放";
            musicStatus.className = "music-status success";
        });
        
        backgroundMusic.addEventListener('error', function() {
            musicStatus.textContent = "音乐加载失败，请检查文件路径和格式";
            musicStatus.className = "music-status error";
        });
        
        musicToggle.addEventListener('click', function() {
            if (isPlaying) {
                backgroundMusic.pause();
                musicToggle.innerHTML = '<span id="musicIcon">▶️</span> 播放音乐';
                musicStatus.textContent = "音乐已暂停";
                musicStatus.className = "music-status";
            } else {
                // 尝试播放音乐
                const playPromise = backgroundMusic.play();
                
                if (playPromise !== undefined) {
                    playPromise.then(() => {
                        // 播放成功
                        musicToggle.innerHTML = '<span id="musicIcon">⏸️</span> 暂停音乐';
                        musicStatus.textContent = "正在播放音乐";
                        musicStatus.className = "music-status success";
                        isPlaying = true;
                    }).catch(error => {
                        // 播放失败
                        musicStatus.textContent = "音乐播放失败：" + error.message;
                        musicStatus.className = "music-status error";
                        console.error("音乐播放错误:", error);
                    });
                }
            }
        });
        
        // 添加音量控制
        backgroundMusic.volume = 0.5; // 设置初始音量
        
        // 自动预加载音乐
        window.addEventListener('load', function() {
            // 尝试加载音乐
            backgroundMusic.load();
        });
    </script>
</body>
</html>